﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using QAQ;

namespace OAO
{
    //to physical ctrl and macros
    class GameCtrl
    {
        private JoyControl mJoyControl;

        //Shunpo
        public bool Item7Available;
        public bool ShunpoReleased;
        public bool ShunpoCancled;
        private static Bitmap mBitmap;
        private static Bitmap mBitmap2;

        //
        
        public GameCtrl() 
        {
            mJoyControl = new JoyControl();
            mBitmap = new Bitmap("s.png");
            mBitmap2 = new Bitmap("s2.png");
        }

        public void MacroShunpo()
        {
            Rectangle r=new Rectangle(244,1000,25,11);
            using (Bitmap b = new Bitmap(r.Width,r.Height))
            {
                using (Graphics g = Graphics.FromImage(b))
                {
                    g.CopyFromScreen(new Point(r.Left, r.Top),
                                     new Point(0, 0),
                                     new Size(r.Width, r.Height));
                }
                Item7Available = bmapComp.CompareMemCmp(b, mBitmap) || bmapComp.CompareMemCmp(b, mBitmap2);
            }
            
            if (Item7Available)
            {
                this.mJoyControl.KeyDown(JoyControl.JOY_KEYS.Item7);
                while (ShunpoReleased == false)
                {
                    if (ShunpoCancled)
                    {
                        this.mJoyControl.KeyUp(JoyControl.JOY_KEYS.Item7);
                        return;
                    }
                    System.Threading.Thread.Sleep(10);
                }
                //System.Threading.Thread.Sleep(Form1.mInt32Keydelay);
                this.mJoyControl.KeyUp(JoyControl.JOY_KEYS.Item7);
            }
            else
            {
                this.mJoyControl.KeyDown(JoyControl.JOY_KEYS.Item6);
                while (ShunpoReleased == false)
                {
                    if (ShunpoCancled)
                    {
                        this.mJoyControl.KeyUp(JoyControl.JOY_KEYS.Item6);
                        return;
                    }
                    System.Threading.Thread.Sleep(10);
                }
                //System.Threading.Thread.Sleep(Form1.mInt32Keydelay);
                this.mJoyControl.KeyUp(JoyControl.JOY_KEYS.Item6);
            }
            System.Threading.Thread.Sleep(Form1.mI32NxtKeyDelay);

            this.mJoyControl.KeyDown(JoyControl.JOY_KEYS.SkillE);
            System.Threading.Thread.Sleep(Form1.mI32KeyPeriod);
            this.mJoyControl.KeyUp(JoyControl.JOY_KEYS.SkillE);
        }

    }
}
